<!--
 * 严肃声明：
 * 开源版本请务必保留此注释头信息，若删除我方将保留所有法律责任追究！
 * 可正常分享和学习源码，不得用于违法犯罪活动，违者必究！
 * Copyright (c) 2022 APThink David唐 all rights reserved.
 * 版权所有，侵权必究！
 *
-->
<script lang="ts" setup>
import { type IOptionNode } from '@/contants'
import { cache } from '@/utils'
import { onMounted, ref, type Ref } from 'vue'

const model = defineModel()
const dataOptions: Ref<Array<IOptionNode> | undefined> = ref([])
const props = defineProps({
  category: {
    type: String,
    required: true
  },
  multiple: {
    type: Boolean,
    required: false
  }
})

onMounted(() => {
  console.log("SysDataSelect mounted!")
  cache.getSysdata(props.category).then(d=>{
    dataOptions.value = d as IOptionNode[]
  })
  console.log(dataOptions.value)
})
</script>

<template>
  <el-form-item :label="$t('label.' + props.category)">
    <el-select v-model="model" :placeholder="$t('label.' + props.category + 'Tip')" clearable :multiple="props.multiple">
      <el-option
        v-for="o in dataOptions"
        :key="o.id"
        :label="$t(props.category + '.' + o.value)"
        :value="o.value"
      />
    </el-select>
  </el-form-item>
</template>

<style></style>
